//
// Decompiled by Jadx - 387ms
//
package ed;

import com.google.gson.Gson;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.TreeMap;

public final class a {
    public static final Charset a = Charset.forName("UTF-8");
    public static final Gson b = new Gson();

    /* JADX WARN: Removed duplicated region for block: B:13:0x0032 A[Catch: UnsupportedEncodingException -> 0x006c, LOOP:0: B:11:0x002c->B:13:0x0032, LOOP_END, TryCatch #0 {UnsupportedEncodingException -> 0x006c, blocks: (B:2:0x0000, B:6:0x0014, B:9:0x001b, B:10:0x0024, B:11:0x002c, B:13:0x0032, B:15:0x005f, B:19:0x0021), top: B:1:0x0000 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static String c(String str, TreeMap treeMap) {
        try {
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            if (str.indexOf(38) <= 0 && str.indexOf(63) <= 0) {
                sb.append("?");
                for (Map.Entry entry : treeMap.entrySet()) {
                    String encode = URLEncoder.encode(String.valueOf(entry.getValue()), a.name());
                    sb.append((String) entry.getKey());
                    sb.append("=");
                    sb.append(encode);
                    sb.append("&");
                }
                sb.deleteCharAt(sb.length() - 1);
                return sb.toString();
            }
            sb.append("&");
            while (r6.hasNext()) {
            }
            sb.deleteCharAt(sb.length() - 1);
            return sb.toString();
        } catch (UnsupportedEncodingException unused) {
            return str;
        }
    }

    public static String d(String str) {
        return ("".equals(str) || !str.contains("?")) ? str : str.substring(0, str.indexOf(63));
    }
}
